package com.ruoyi.oa.service.impl;

import java.util.List;

import com.ruoyi.aftserv.domain.ManageGradeClass;
import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.utils.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.oa.mapper.ManageStudentMapper;
import com.ruoyi.oa.domain.ManageStudent;
import com.ruoyi.oa.service.IManageStudentService;
import com.ruoyi.common.core.text.Convert;

/**
 * 学生Service业务层处理
 * 
 * @author 张艳羽
 * @date 2024-08-20
 */
@Service
public class ManageStudentServiceImpl implements IManageStudentService 
{
    @Autowired
    private ManageStudentMapper manageStudentMapper;

    /**
     * 查询学生
     * 
     * @param id 学生主键
     * @return 学生
     */
    @Override
    public ManageStudent selectManageStudentById(Long id)
    {
        return manageStudentMapper.selectManageStudentById(id);
    }

    /**
     * 查询学生列表
     * 
     * @param manageStudent 学生
     * @return 学生
     */
    @Override
    public List<ManageStudent> selectManageStudentList(ManageStudent manageStudent)
    {
        return manageStudentMapper.selectManageStudentList(manageStudent);
    }

    /**
     * 新增学生
     * 
     * @param manageStudent 学生
     * @return 结果
     */
    @Override
    public int insertManageStudent(ManageStudent manageStudent)
    {
        return manageStudentMapper.insertManageStudent(manageStudent);
    }

    /**
     * 修改学生
     * 
     * @param manageStudent 学生
     * @return 结果
     */
    @Override
    public int updateManageStudent(ManageStudent manageStudent)
    {
        return manageStudentMapper.updateManageStudent(manageStudent);
    }

    /**
     * 批量删除学生
     * 
     * @param ids 需要删除的学生主键
     * @return 结果
     */
    @Override
    public int deleteManageStudentByIds(String ids)
    {
        return manageStudentMapper.deleteManageStudentByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除学生信息
     * 
     * @param id 学生主键
     * @return 结果
     */
    @Override
    public int deleteManageStudentById(Long id)
    {
        return manageStudentMapper.deleteManageStudentById(id);
    }

    @Override
    public boolean checkStunoUnique(ManageStudent student) {
        Long stuId = StringUtils.isNull(student.getId()) ? -1L : student.getId();
        ManageStudent info = this.manageStudentMapper.checkStunoUnique(student.getStuno());
        if (StringUtils.isNotNull(info) && info.getId().longValue() != stuId.longValue())
        {
            return UserConstants.NOT_UNIQUE;
        }
        return UserConstants.UNIQUE;
    }

    @Override
    public ManageStudent getStudentByStuno(String stuno, String status) {
        return this.manageStudentMapper.getStudentByStuno(stuno, status);
    }

    @Override
    public ManageStudent selectStudentByStunNoAndOpenID(String stuno, String openId) {
        return this.manageStudentMapper.selectStudentByStunNoAndOpenID(stuno, openId);
    }
}
